﻿using Basic.FlowGatewayModule.ExtendService;
using Basic.HrOperateLogModular;
using Basic.HrOperateLogModular.ApiRouteFilter;
using WeDonekRpc.Client.Attr;
using WeDonekRpc.HttpApiGateway;
using WeDonekRpc.HttpApiGateway.Interface;

namespace Basic.FlowGatewayModule
{
    public class FlowGatewayApiModular : BasicApiModular
    {
        public FlowGatewayApiModular () : base("FlowApi_Gateway")
        {
        }

        protected override void Load ( IHttpGatewayOption option, IModularConfig config )
        {
            option.Option.Option.LoadModular<HrOpLogModular>();
            this.AddFilters<OperateLogFilter>();
            config.ApiRouteFormat = "/flow/{controller}/{name}";
            option.IocBuffer.SetDefLifetimeType(( body ) =>
            {
                if ( body.To.FullName.StartsWith("Basic.FlowGatewayModule.Interface.") || body.To.FullName.StartsWith("Basic.FlowGatewayModule.ExtendService.Interface.") )
                {
                    body.SetLifetimeType(ClassLifetimeType.SingleInstance);
                }
            });
        }
        protected override void Init ()
        {
            EnumService.Load();
        }
    }
}